var MutationViewerApp = MutationViewerApp || {};
MutationViewerApp.view = MutationViewerApp.view || {};

MutationViewerApp.view.MutationPlotView = Backbone.View.extend({
    initialize: function(options) {
        this.dispatcher = options.dispatcher;

        this.collection.on('reset', function() {
            this.render();
        }, this);
    },

    render: function() {
        this.$el.empty();

        if (this.collection.toJSON().length === 0)
        {
            return this;
        }

        var data = this.collection.toJSON()[0];

        var options = {
            location_tick_height: 25,
            band_label_width: 70,
            protein_scale_width: 1500,
            protein_scale_y: 40,
            protein_vertical_padding: 10,
            signature_height: 10,
            enable_transitions: true,
            enable_mutation_stems: true,
            mutation_layout: 'all_subtypes',
            mutation_stem_height: 50,
            mutation_shape_width: 8,
            mutation_group_padding: 0,
            mutation_colors: {
                Nonsense_Mutation: 'red',
                Silent: 'green',
                Frame_Shift_Del: 'gold',
                Frame_Shift_Ins: 'gold',
                Missense_Mutation: 'blue'
            },
            plot: {
                horizontal_padding: 30,
                vertical_padding: 30
            }
        };

        this.$el.mutationviewplot(data, options);

        return this;
    }
});
